/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.ufba.lasid.tests;

import br.ufba.lasid.ds.fd.FailureDetector;
import br.ufba.lasid.ds.replication.ReplicatedResourceManager;
import br.ufba.lasid.utils.DRBDResource;

/**
 *
 * @author aliriosa
 */
public class TReplicatedResource {

    /**
     * This class may be called by passing the args 0-device 1-drbd directory,
     * 2-drbd resource, 3-virtualMachineName@localhostIP,
     * 4-virtualMachineName@remotehostIP example: TReplicatedResource /dev/drbd7
     * /mnt/drbd7/ r7 mini-ubuntu@10.10.10.10 mini-ubuntu@10.10.10.11
     *
     * @192.168.188.15 10
     * @192.168.188.16
     * @param args
     * @throws Exception
     */
    public static void main(String[] args) throws Exception {

        ReplicatedResourceManager replicator = new ReplicatedResourceManager(new DRBDResource(args[0], args[1], args[2]));

        FailureDetector detector = new FailureDetector();
        detector.register(args[3], true);
        detector.register(args[4], false);
        replicator.setDetector(detector);
        replicator.getDetector().buildup();
        replicator.getDetector().setPeriod(5000L);
        replicator.getDetector().setTimeout(200L);
        replicator.getDetector().startup();

        replicator.register(args[3], true);
        replicator.register(args[4], false);
        replicator.buildup();
        replicator.setPeriod(20000L);
        replicator.startup();
    }
}
